//
//  ViewController.swift
//  LNGClickAreaDemo
//
//  Created by sun on 2022/8/5.
//

import UIKit

class ViewController: UIViewController {
    lazy var closeButton: LNGClickAreaButton = {
        let closeButton = LNGClickAreaButton.init(frame: CGRect.zero)
        closeButton.titleLabel?.textColor = .black
        closeButton.backgroundColor = .green
        closeButton.titleLabel?.text = "取消"
        closeButton.titleLabel?.textAlignment = .center
        closeButton.titleLabel?.font = UIFont.systemFont(ofSize: 17)
        closeButton.clickAreaOffset = 10
        return closeButton
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
    }

    func setupUI() {
        closeButton.frame = CGRect.init(x: 100, y: 100, width: 120, height: 40)
        view.addSubview(closeButton)
        closeButton.addTarget(self, action: #selector(clickCloseButton), for: .touchUpInside)
    }
    
    //点击closeButton边缘外边 0-10像素, 点击事件依旧响应
    @objc func clickCloseButton() {
        print("点击了按钮")
    }
}

